// 初始信息
export const initState = {
    // 用户信息
    info: sessionStorage.getItem("info")?JSON.parse(sessionStorage.getItem("info")):{}
}
// 修改的逻辑
export const reducer = (state, action) => {
    switch (action.type) {
        //修改info的逻辑
        case "changeInfo":
            //{type:"changeInfo",info:{token:"",uid:""}}
            return {
                ...state,
                info: action.info
            }
            break;
        default:
            return state;
    }
}
// 修改方法
export const actions={
    changeInfo:(info)=>{
        // 同步到本地存储
        if(info.token){
            sessionStorage.setItem("info",JSON.stringify(info))
        }else{
            sessionStorage.removeItem("info")
        }
        return {type:"changeInfo",info}
    }
}